package org.wadael.waverobotfrmwrk.simple;

import org.wadael.waverobotfrmwrk.WadRobot;
import org.wadael.waverobotfrmwrk.utils.BlipUtils;

import com.google.wave.api.Blip;
import com.google.wave.api.event.BlipSubmittedEvent;
import com.google.wave.api.event.Event;
import com.google.wave.api.event.WaveletParticipantsChangedEvent;
import com.google.wave.api.event.WaveletSelfAddedEvent;
import com.google.wave.api.impl.EventMessageBundle;

@SuppressWarnings("serial")
public abstract class BlipAppenderRobot extends WadRobot {
	
	@Override
	protected void reactToSubmittedBlip(EventMessageBundle bundle, Blip blip, Event event) {
		log("IN appender reactToSubmittedBlip"); // TODO remove
		log(  BlipUtils.getEventBlipText(event)  ); // TODO remove
		
		BlipUtils.appendNewBlipWithContent(event, getTextToAppend( BlipUtils.getEventBlipText(event) ) );		
	}
	
	/**
	 * @return a String that will form a new blip, itself the child of the blip
	 *         YOUR code will react from. Or null if no new blip should be added
	 */
	protected abstract String getTextToAppend(String textOfTheBlipToReactFrom);


	/* 
	 * Because of this issue, the following methods are MANDATORY.
	 * http://code.google.com/p/google-wave-resources/issues/detail?id=711
	 * 
	 * Looks weird to you ? Try without ;)
	 */
	
	@Override
	public void onBlipSubmitted(BlipSubmittedEvent event) { super.onBlipSubmitted(event);}
	
	@Override
	public void onWaveletParticipantsChanged(WaveletParticipantsChangedEvent event) { super.onWaveletParticipantsChanged(event); }
	
	@Override
		public void onWaveletSelfAdded(WaveletSelfAddedEvent event) { super.onWaveletSelfAdded(event);	}
	
	// Should add more :(
}
